package hos.base.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import hos.base.IViewLoading;
import hos.base.LoadingDialog;


/**
 * <p>Title: ProgressActivity </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2021/2/6 20:14
 */
public abstract class ProgressActivity extends BaseActivity {

    @Nullable
    private LoadingDialog mProgressDialog;

    public ProgressActivity() {
    }

    public ProgressActivity(@LayoutRes int contentLayoutId) {
        super(contentLayoutId);
    }


    @NonNull
    public IViewLoading getProgressDialog() {
        if (mProgressDialog == null) {
            mProgressDialog = new LoadingDialog(new android.app.ProgressDialog(activity()));
        }
        return mProgressDialog;
    }

    @Override
    public void onDestroy() {
        if (mProgressDialog != null) {
            mProgressDialog.onDestroy();
        }
        super.onDestroy();
    }
//
//    @Override
//    public void showLoading(@StringRes int titleId) {
//        showLoading(getResources().getString(titleId));
//    }
//
//    @Override
//    public void showLoading(@NonNull String title, boolean isDismissOnBackPressed,
//                            boolean isDismissOnTouchOutside) {
//        postOnMain(new Runnable() {
//            @Override
//            public void run() {
//                if (mProgressDialog == null) {
//                    getProgressDialog().showLoading(title, isDismissOnBackPressed, isDismissOnTouchOutside);
//                    return;
//                }
//                mProgressDialog.showLoading(title, isDismissOnBackPressed, isDismissOnTouchOutside);
//            }
//        });
//    }
//
//    @Override
//    public void loadingStyle(boolean isLoading) {
//        getProgressDialog().loadingStyle(isLoading);
//    }
//
//    @Override
//    public void loadingProgress(int progress) {
//        getProgressDialog().loadingProgress(progress);
//    }
//
//    @Override
//    public void hideLoading() {
//        if (mProgressDialog == null) {
//            return;
//        }
//        postOnMain(new Runnable() {
//            @Override
//            public void run() {
//                if (mProgressDialog == null) {
//                    return;
//                }
//                mProgressDialog.hideLoading();
//            }
//        });
//    }

}
